package com.weimei.conversionTreasure.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;

import com.chad.library.BR;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.app.AppViewModelFactory;
import com.weimei.conversionTreasure.databinding.ActivityYearDetailBinding;
import com.weimei.conversionTreasure.viewModel.JyDetailVM;
import com.weimei.conversionTreasure.viewModel.YearDetailVM;

import me.goldze.mvvmhabit.base.BaseActivity;

public class YearDetailActivity extends BaseActivity<ActivityYearDetailBinding, YearDetailVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_year_detail;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        viewModel.types.set(types);
        viewModel.time.set(times.substring(5,7));
        viewModel.curY.set(times.substring(0,5));
    }

    @Override
    public YearDetailVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, (ViewModelProvider.Factory) factory).get(YearDetailVM.class);
    }


    String types,times;
    @Override
    public void initParam() {
        super.initParam();
        types = getIntent().getStringExtra("type");
        times = getIntent().getStringExtra("time");
    }

}